/***
 *                    _ooOoo_
 *                   o8888888o
 *                   88" . "88
 *                   (| -_- |)
 *                    O\ = /O
 *                ____/`---'\____
 *              .   ' \\| |// `.
 *               / \\||| : |||// \
 *             / _||||| -:- |||||- \
 *               | | \\\ - /// | |
 *             | \_| ''\---/'' | |
 *              \ .-\__ `-` ___/-. /
 *           ___`. .' /--.--\ `. . __
 *        ."" '< `.___\_<|>_/___.' >'"".
 *       | | : `- \`.;`\ _ /`;.`/ - ` : | |
 *         \ \ `-. \_ __\ /__ _/ .-` / /
 * ======`-.____`-.___\_____/___.-`____.-'======
 *                    `=---='
 *
 * .............................................
 *          佛祖保佑             永无BUG
 *@author wwh
 *@date 2022年07月02日10:52
 */
package com.qfedu.tantu.controller;

import com.qfedu.tantu.service.intf.CollectService;
import com.qfedu.tantu.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/api/collect/")
@Api("文章收藏和收藏查询操作")
@CrossOrigin
public class CollectController {
    @Resource
    private CollectService collectService;

    @ApiOperation("文章收藏")
    @GetMapping("insertCollect.do")
    public R insertCollect(int aid, HttpServletRequest request){
        //传递token 采取请求消息头
        return collectService.insertCollect(aid,request.getIntHeader("bbtoken"));
    }
    @ApiOperation("收藏查询")
    @GetMapping("selectAll.do")
    public R selectAll(HttpServletRequest request){
        //传递token 采取请求消息头
        return collectService.selectAll(request.getIntHeader("bbtoken"));
    }

    @ApiOperation("查询单篇文章")
    @GetMapping("userCollect.do")
    public R userCollect(int id){
        return collectService.userCollect(id);
    }

    @ApiOperation("用户查询")
    @GetMapping("user.do")
    public R userOne(HttpServletRequest request){
        //传递token 采取请求消息头

        return collectService.userOne(request.getIntHeader("bbtoken"));
    }
}
